package cn.skyquant.quant4j.task.boot.entity;

import cn.skyquant.quant4j.api.enums.BorkerType;
import cn.skyquant.quant4j.sdk.enums.Status;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import java.util.Objects;

public class Account {
    @Id
    public Integer id;
    public String code;
    @Column(name="borker_type")
    public BorkerType borkerType;
    public String parentCode;//父账户id
    public String name;//账户名称
    public String type;//账户类型
    public double balance;
    public double equity;
    public double usedMargin;
    public String borkerName;   //券商名称
    public String currency;     //账户货币
    @JoinColumns(value = {
            @JoinColumn(name = "id")
    })
    public User user;
    @Column(name="notice")
    public Status notice;     //是否短信通知

    public Account() {
    }

    public Account(String code, BorkerType borkerType) {
        this.code = code;
        this.borkerType = borkerType;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (!(o instanceof Account)) return false;
        Account account = (Account) o;
        return Objects.equals(code, account.code) &&
                borkerType == account.borkerType;
    }

    @Override
    public int hashCode() {
        return Objects.hash(code, borkerType);
    }
}
